import Spreadsheet from "x-data-spreadsheet";
export const locales = {
  "zh-CN": {
    toolbar: {
        undo: "撤销",
        redo: "重做",
        print: "打印",
        paintformat: "格式刷",
        clearformat: "清除格式",
        format: "数据格式",
        fontName: "字体",
        fontSize: "字号",
        fontBold: "加粗",
        fontItalic: "斜体",
        underline: "下划线",
        strike: "删除线",
        textColor: "文字颜色",
        fillColor: "填充颜色",
        border: "边框",
        merge: "合并单元格",
        align: "水平对齐",
        valign: "垂直对齐",
        textwrap: "自动换行",
        freeze: "冻结",
        formula: "函数",
        more: "更多",
    },
    contextmenu: {
        copy: "复制",
        cut: "剪切",
        paste: "粘贴",
        pasteValue: "粘贴值",
        pasteFormat: "粘贴格式",
        hide: "隐藏",
        insertRow: "插入行",
        insertColumn: "插入列",
        deleteRow: "删除行",
        deleteColumn: "删除列",
        deleteCell: "删除单元格",
        deleteCellText: "删除内容",
        validation: "数据验证",
        customStyle: "设置样式",
        mergeCells: "合并单元格",
        unmergeCells: "取消合并",
    },
    button: {
        confirm: "确认",
        cancel: "取消",
    },
    sort: {
        desc: "降序",
        asc: "升序",
    },
    dialog: {
        styleHeader: "单元格样式",
        textColor: "文字颜色:",
        bgColor: "背景颜色:",
        fontWeight: "字体粗细:",
        fontStyle: "字体样式:",
        normal: "正常",
        bold: "粗体",
        italic: "斜体",
        apply: "应用",
        cancel: "取消",
    },
},
"en-US": {
    toolbar: {
        undo: "Undo",
        redo: "Redo",
        print: "Print",
        paintformat: "Format painter",
        clearformat: "Clear format",
        format: "Format",
        fontName: "Font",
        fontSize: "Font size",
        fontBold: "Bold",
        fontItalic: "Italic",
        underline: "Underline",
        strike: "Strike through",
        textColor: "Text color",
        fillColor: "Fill color",
        border: "Border",
        merge: "Merge cells",
        align: "Horizontal align",
        valign: "Vertical align",
        textwrap: "Text wrap",
        freeze: "Freeze",
        formula: "Formula",
        more: "More",
    },
    contextmenu: {
        copy: "Copy",
        cut: "Cut",
        paste: "Paste",
        pasteValue: "Paste Value",
        pasteFormat: "Paste format",
        hide: "Hide",
        insertRow: "Insert row",
        insertColumn: "Insert column",
        deleteRow: "Delete row",
        deleteColumn: "Delete column",
        deleteCell: "Delete cell",
        deleteCellText: "Delete text",
        validation: "Data validation",
        customStyle: "Custom style",
        mergeCells: "Merge cells",
        unmergeCells: "Unmerge cells",
    },
    button: {
        confirm: "Confirm",
        cancel: "Cancel",
    },
    sort: {
        desc: "Sort Z-A",
        asc: "Sort A-Z",
    },
    dialog: {
        styleHeader: "Cell Style",
        textColor: "Text color:",
        bgColor: "Background color:",
        fontWeight: "Font weight:",
        fontStyle: "Font style:",
        normal: "Normal",
        bold: "Bold",
        italic: "Italic",
        apply: "Apply",
        cancel: "Cancel",
    },
  },
}

// 设置locale
export function setLocale(lang:string, locale: "zh-CN"|"en-US") {
  Spreadsheet.locale(lang, {
    toolbar: {
        undo: locales[locale].toolbar.undo,
        redo: locales[locale].toolbar.redo,
        print: locales[locale].toolbar.print,
        paintformat: locales[locale].toolbar.paintformat,
        clearformat: locales[locale].toolbar.clearformat,
        format: locales[locale].toolbar.format,
        fontName: locales[locale].toolbar.fontName,
        fontSize: locales[locale].toolbar.fontSize,
        fontBold: locales[locale].toolbar.fontBold,
        fontItalic: locales[locale].toolbar.fontItalic,
        underline: locales[locale].toolbar.underline,
        strike: locales[locale].toolbar.strike,
        textColor: locales[locale].toolbar.textColor,
        fillColor: locales[locale].toolbar.fillColor,
        border: locales[locale].toolbar.border,
        merge: locales[locale].toolbar.merge,
        align: locales[locale].toolbar.align,
        valign: locales[locale].toolbar.valign,
        textwrap: locales[locale].toolbar.textwrap,
        freeze: locales[locale].toolbar.freeze,
        formula: locales[locale].toolbar.formula,
        more: locales[locale].toolbar.more,
    },
    contextmenu: {
        copy: locales[locale].contextmenu.copy,
        cut: locales[locale].contextmenu.cut,
        paste: locales[locale].contextmenu.paste,
        pasteValue: locales[locale].contextmenu.pasteValue,
        pasteFormat: locales[locale].contextmenu.pasteFormat,
        hide: locales[locale].contextmenu.hide,
        insertRow: locales[locale].contextmenu.insertRow,
        insertColumn: locales[locale].contextmenu.insertColumn,
        deleteRow: locales[locale].contextmenu.deleteRow,
        deleteColumn: locales[locale].contextmenu.deleteColumn,
        deleteCell: locales[locale].contextmenu.deleteCell,
        deleteCellText: locales[locale].contextmenu.deleteCellText,
        validation: locales[locale].contextmenu.validation,
    },
    button: {
        confirm: locales[locale].button.confirm,
        cancel: locales[locale].button.cancel,
    },
    sort: {
        desc: locales[locale].sort.desc,
        asc: locales[locale].sort.asc,
    },
  })
}